<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>BufPay.com java Demo</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<form>
    <p><input id="inputmoney" type="text" name="inputmoney" class="form-control" placeholder="请输入金额" required></p>

    <div class="radio">
        <label>
            <p><input type="radio" name="demo1" id="demo1-alipay" value="alipay" checked="">
                支付宝支付</p>
        </label>
    </div>
    <div class="radio">
        <label>
            <p><input type="radio" name="demo1" id="demo1-weixin" value="wechat">
                微信支付</p>
        </label>
    </div>
    <button type="button" id="demoBtn1">确认购买</button>
</form>
<form style='display:none;' id='formpay' name='formpay' method='post' action='https://bufpay.com/api/pay/见后台'>
    <input name='order_id' id='order_id' type='text' value=''/>
    <input name='order_uid' id='order_uid' type='text' value=''/>
    <input name='name' id='name' type='text' value='' />
    <input name='pay_type' id='pay_type' type='text' value='' />
    <input name='price' id='price' type='text' value=''/>
    <input name='notify_url' id='notify_url' type='text' value=''/>
    <input name='return_url' id='return_url' type='text' value=''/>
    <input name='feedback_url' id='feedback_url' type='text' value=''/>
    <input name='sign' id='sign' type='text' value=''/>
    <input type='submit' id='submitdemo1'>
</form>
<script>
    function getistype(){
        return ($("#demo1-alipay").is(':checked') ? "alipay" : "wechat" );
    }
    $("#demoBtn1").click(function() {

        $.ajax({
            url: "/pay/pay",
            data: {
                price: $("#inputmoney").val(),
                pay_type: getistype(),
                name:"bufpay"
            },
            success:function (res) {
                if(res.code==200){
                    console.log(res.data)
                    $("#order_id").val(res.data.order_id);
                    $("#order_uid").val(res.data.order_uid);
                    $("#name").val(res.data.name);
                    $("#pay_type").val(res.data.pay_type);
                    $("#price").val(res.data.price);
                    $("#notify_url").val(res.data.notify_url);
                    $("#return_url").val(res.data.return_url);
                    $("#feedback_url").val(res.data.feedback_url);
                    $("#sign").val(res.data.sign);
                    $("#submitdemo1").click();
                }
            }
        });
    })
</script>
</body>
</html>